import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"
import user from './user'

Vue.use(Vuex)
let Store
if (process.browser) {
  // 客户端
  Store = () => {
    return new Vuex.Store({
      modules:{
        user,
      },
      plugins:[
        createPersistedState({
          storage: window.localStorage,
          // 需要持久化的模块
          reducer(val){
            return {
              user:val.user,
            }
          }
        })
      ]
    })
  }
}

export default Store


